????ࡱ> ^`]9 R&bjbj2b"lL!<(DDDDDDD  $<# \%j DDDDD DD DDD D :[,D RT/k   0!R% %Printing Reports to HTML  HYPERLINK "http://www.techtricks.com/paradox/rpt2html.php" http://www.techtricks.com/paradox/rpt2html.php Audience: Intermediate Question: How do I publish reports to HTML files using ObjectPAL? Answer: Either start the Report HTML Expert or call the ObjectPAL library that the Expert itself uses. The Expert is easier to implement and lets your users control the publication process while the library lets you control the process; however, it requires more work. This article shows how to handle both tasks. Launching the Report HTML Expert Starting the Report HTML Expert is fairly straightforward; simply open the report and then trigger the menu action that launches the Expert, as shown in the following code sample. method pushButton(var eventInfo Event) var rpt Report endVar rpt.open( ":work:customer" ) rpt.menuAction( MenuWriteAsHTML ) rpt.close() endMethod This launches the Report HTML Expert and lets your users control the details of the publication process, including the target filename, background color, and so on. For more control over the process, use the mechanism the Expert uses. Specifically, call the html_PublishReport method of Paradox Internet Publishing Library (HTMLIB01.LDL). Corel first released the Paradox Internet Publishing Library with Paradox 8.0 and they've updated it in subsequent versions. Unfortunately, they've not updated the documentation. The following section shows how to use the library in later versions of Paradox. Using the Internet Publishing Library This section shows how to use the Paradox Internet Publishing Library to publish reports to HTML documents, regardless of the version you're using. As with any library, some assembly is required. To demonstrate the basic process, you'll create a script that publishes the sample Customer report provided with most versions of Paradox: Start by changing the Paradox working directory to the one containing the Paradox sample files. Create a new script and then save it as HtmlDemo.ssl. When the Run window appears, press Ctrl+Space to open the Object Explorer. Choose the Method tab and then open the Type window. Now, declare the following record type: type _HTMLReport = record ; Add these if you're using Paradox 8.0 or later strURI String ; URI (or output file name) strTitle String ; Document title iBGColor LongInt ; Background color iTextColor LongInt ; Text color mHeader Memo ; (filled) Header template mTemplate Memo ; (filled) Main template lStatic Logical ; Static output? (FALSE = Dynamic) lMsg Logical ; Show status line messages? ; Add this if you're using Paradox 9, 10, or 11. lServlet Logical ; Undocumented ; Add these if you're using Paradox 10 or 11. lDocHyperlink Logical ; Undocumented strPublishAs String ; Undocumented endRecord endType Be sure to declare the items appropriate for your version of Paradox. If you're using Paradox 8, don't add the lServlet, lDocHyperlink, or strPublishAs items; otherwise, you'll receive errors (described later). Note: This is the only step that involves version specific problems. The remaining steps apply to all versions of Paradox released since 8.0. Next, use the Object Explorer to open the script's Uses window and then add the following prototypes: uses ObjectPAL HTMLPublish_Report( var rSource Report, var HTMLReport _HTMLReport ) Logical _LaunchBrowser( strFileName String, lWait Logical ) Logical endUses These describe the routines you'll be calling from the Internet Publishing Library. Note that you need to pass an _HTMLReport variable to the HTMLPublish_Report method. Next, create a custom method called reportPublish() and then add the following code: method reportPublish( strRptName String, strSaveAs String ) Logical var rptWebPub Report ; The report being published. _hrWebPub _htmlReport ; Details for the library routine. libWebPub Library ; Pointer to the publishing library. fbiSaveAs fileBrowserInfo ; Information for Save As dialog. loRetval Logical ; Value returned to calling proc. endVar const ERRTITLE = "HTML Publishing Error" ; title for error dialogs. endConst ; If we can't open the library, we cannot continue. loRetval = libWebPub.open( expertsDir() + "\\HTMLIB01" ) If not loRetval then errorShow( ERRTITLE, "Reason: Unable to load publishing " + "library; see details..." ) return loRetval endIf ; Open the report. loRetval = rptWebPub.open( strRptName ) If not loRetval then errorShow( ERRTITLE, "Reason: The report failed to " + "open; see details..." ) return loRetval endIf rptWebPub.DesignModified = FALSE ; Now, provide the required details. _hrWebPub.strURI = strSaveAs _hrWebPub.strTitle = rptWebPub.getTitle() _hrWebPub.iBGColor = Black _hrWebPub.iTextColor = White _hrWebPub.lStatic = TRUE _hrWebPub.lMsg = TRUE ; Try to publish the report. loRetval = libWebPub.htmlPublish_Report( rptWebPub, _hrWebPub ) If not loRetval then errorShow( ERRTITLE, "Reason: The publishing routine failed; " + "see details." ) else If msgQuestion( "Report Sucessfully Published", "Your report has been published. Would " + "you like to view the final file in " + "your Internet browser?" ) = "Yes" then If not libWebPub._launchBrowser( _hrWebPub.strURI, Yes ) then errorShow( "Can't Preview HTML", "Reason: The " + "browser failed to launch; see " + "details..." ); endIf endIf endIf ; Close the report and the library. try rptWebPub.close() onFail ; do nothing as the report is already closed. endtry If libWebPub.isAssigned() then libWebPub.close() endIf endMethod Finally, add the following code to your script's Run() event: ReportPublish( ":work:customer.rsl", "c:\\report.html" ) Save and run your script. Granted, that's quite a bit of work; however, when finished, you'll have a script that can be easily modified to publish any report to an HTML document. A sample .ZIP file for this article is available from our  HYPERLINK "http://www.techtricks.com/download/paradox/samples/rpt2html.zip" Download area. It contains a form that lets you browse for the report to be published. The form also contains two buttons; each illustrates one of the approaches shown above. The .ZIP file also contains a completed version of the script created above. Troubleshooting This section lists errors that might occur while you're setting things up and briefly explains the most common solutions. The specified string identifer is invalid. This is usually caused by passing an alias in the target filename, e.g. the name of your final HTML document. Use care to pass fully qualified filenames, e.g. ones containing the drive letter, pathname, and file extension. An error occured trying to access a record structure. An unexpected field number was encountered. This indicates a problem with your declaration of the _HTMLReport type. The declaration in HTMLIB01.LDL contains different fields and Paradox cannot determine how to handle the differences. Usually, you'll get this when using Paradox 9 or later and relying solely on the documented declaration of _HTMLReport. To fix the error, refer to Step 5 in the previous walkthrough and correct your declaration of _HTMLReport to match the one appropriate for your version of Paradox. What about PublishTo()? If you searched the ObjectPAL Help files while trying to learn how to publish reports to HTML documents, you may have come across the PublishTo() method of the Report class. While the documentation suggests you can use this to publish reports to HTML files, we have not yet found a version of Paradox that supports this. While the Help topic provides sample code that compiles (e.g. it doesn't raise a syntax error), it simply doesn't work in any version of Paradox we've tested. This appears to be a bug and the previous approaches are the only known workarounds that do not involve other software applications. (You can, for example, use a word processor to extract data from your Paradox tables and then use that product's publishing features to create HTML documents. In some cases, this may be more desireable.) VWX2S $ ; C  , 6 | ՍՍՀ|||x|5\6]CJOJQJ^JaJ<CJaJ!B*CJOJPJQJ^JaJphCJOJQJaJ'5B*CJOJPJQJ\^JaJph5CJOJQJ\aJCJOJQJaJ!B*CJOJPJQJ^JaJpho(0JjU jU5CJ\aJ/n$$Ifr%R& p a&634a $$Ifa$$If &2S.2Apyyooo $If^ $If[$\$$Ifl$$If\%R& (#a&634a$If AHhK $ s T  = j  & F f$If^f  & F$If$If $If[$\$ $If^ .m  >i| q&.,  & F$If$If^ f$If^f & F f$If^f|>B| "" &&&o(CJaJCJOJQJ^JaJ0J jU5\6],pt4t F)23It & F f$If^f@Ai%FGg 5=s1mA & F f$If^fAP\e.78Bl|$If $If[$\$  & F$If f$If^f & F f$If^f| """$$ & &&el$$If\%R& (#a&634a$If $If[$\$$If $If^  & F$If &&01h2P. A!7"7#7$7%S 1DyK /http://www.techtricks.com/paradox/rpt2html.phpyK ^http://www.techtricks.com/paradox/rpt2html.php i@@@ gQe1$$CJKHPJ_HaJmH nHsH tH\`B\ jL 4dd1$@&[$\$+5B*CJKHOJPJQJ\^JaJphA@ -k=W[W"U`" #P} >*B*ph\^`\ gQe (Web)dd1$[$\$%B*CJKHOJPJQJ^JaJphe` HTML Preformatted: 2( Px 4 #\'*.25@91$%B*CJKHOJPJQJ^JaJph"b2S.2AHhK$s T = j . m > i | q &.,pt4t F)23It@Ai%FGg 5=s1mAP\e.78Bl| " """00000000000000000000000000000000000 0 0 0 0 0 0 0 0 0 0  0  0  0  0  0 0 0 0 0 0 0 0 0 0000 0 0 0 0 000 0 0 0 0  0! 0" 0# 0$ 0% 0& 0' 0( 0) 0* 0+ 0, 0- 0. 0/ 00 01 02 03 04 05 06 07 08 09 0: 0; 0< 0= 0> 0? 0@ 0A 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00000000000000 00 00000 00 0000000000&%+A ,A|&&&()*,-./0&'W"XX09&.1AGKSWdky{,6  C K p x ~  4 ; s w D Q o {  " / 4 @ v  &-3@BLU^psw7@BQw IQTbdn (,1LTWegq~ 7m|)6jruFQ[fAY\kJOV[_d+168A)}aj! "" .158AGKSky  C K p x  4 ; s w D Q o { q u &- ,2psw7@w IQ,1LT 7m|)6jr%(8<QT JL29JOV[_d+168Aswak"33333333333333333333333333333333333333333333333333333333333333333333333333333333333333"jackPC:\Documents and Settings\Administrator\Lhb\enje>Y (3)\Printing Reports to HTML.docGR@zv7,Y0ꜻ^`CJOJQJo(^`CJOJQJo(opp^p`CJOJQJo(@ @ ^@ `CJOJQJo(^`CJOJQJo(^`CJOJQJo(^`CJOJQJo(^`CJOJQJo(PP^P`CJOJQJo(^`.^`.pp^p`.@ @ ^@ `.^`.^`.^`.^`.PP^P`.v7,YGRt 跠^!)s,fGhuT"hX{8T"ytY0\_N h΀bk " """@t"P@Unknown Gz Times New Roman5Symbol3& z Arial7&  VerdanaI& ?Arial Unicode MSC"MS Sans SerifC.e0}fԚPMingLiU?5 z Courier New;Wingdings qhcxFcxF;!?!),.:;?]}    " % & ' 2 t%00 0 0 00000013468:<>@BDOPQRTUVWZ\^ \]d([{  5 0 0 00000579;=?ACY[][77x2|"2QPrinting Reports to HTMLjackjackOh+'0   < H T`hpxPrinting Reports to HTML0rinjackingackack Normal.dotpjackl.d1ckMicrosoft Word 9.0 @@e5/k@e5/k՜.+,D՜.+,D hp|  1/;|" Printing Reports to HTML D 8@ _PID_HLINKSAL ;u@http://www.techtricks.com/download/paradox/samples/rpt2html.zipj>/http://www.techtricks.com/paradox/rpt2html.php  !"#$%&'()*+,-./013456789;<=>?@ABCDEFGHIJKLNOPQRSTVWXYZ[\_Root Entry F@T/kaData 21Table:%WordDocument2bSummaryInformation(MDocumentSummaryInformation8UCompObjfObjectPool@T/k@T/k  FMicrosoft Word MSWordDocWord.Document.89q